#include <bits/stdc++.h>
// 2025/01/24
// tag: 
// Author: Zhang Muen
using namespace std;

int n, deep[101];
unordered_map<int, vector<int>> tree;
bool vis[101];
int parent[101]; // 记录每个节点的父节点

void BFS(){
    queue<int> q;
    q.push(1);
    deep[1] = 1;
    int depth = 1, width = 0;
    while (!q.empty()){
        int s = q.size();
        width = max(width, s);
        for (int i = 0; i < s; i++){
            int cur = q.front();
            q.pop();
            for (auto next: tree[cur]){
                if (deep[next] == 0){
                    q.push(next);
                    deep[next] = depth + 1;
                    parent[next] = cur; // 记录父节点
                }
            }
        }
        depth++;
    }
    cout << depth - 1 << endl << width << endl;
}

int dis(int x, int y){
    queue<pair<int, int>> q;
    q.push(make_pair(x, 0)), vis[x] = true;
    while (!q.empty()){
        int cur = q.front().first;
        int d = q.front().second;
        q.pop();
        //cout << cur << " " << d << endl;
        if (cur == y)
            return d;
        for (auto next: tree[cur]){
            if (!vis[next]){
                int distance = (parent[cur] == next) ? 2 : 1; // 根据父节点判断边的方向
                q.push(make_pair(next, d + distance));
                vis[next] = true;
            }
        }
    }
    return -1;
}

signed main()
{
    cin >> n;
    for (int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int x, y;
    cin >> x >> y;
    BFS();
    cout << dis(x, y);
    return 0;
}